// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import pxtovw from 'postcss-px-to-viewport'
const pxtovwPlugin = pxtovw({
// 这里是设计稿宽度 自己修改
  viewportWidth: 1920,
  viewportUnit: 'vw'
})
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  define: {
    'process.env': {}
  },
  base: './',
  server: {
    hmr: true,
    port: 8999,
    host: true,
    open: true,
    proxy: {
      '/ec': {
        target: 'http://112.19.95.219:38000',
        changeOrigin: true
      },
      '/dev-api': {
        target: 'http://47.108.76.236:13001',
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/dev-api/, '')
      },
      '/iserver': {
        target: 'http://112.19.95.219:13002' || '/',
        changeOrigin: true,
        pathRewrite: {
          '^/iserver': '/iserver'
        }
      }
    }
  },
  css: {
    postcss: {
      plugins: [pxtovwPlugin]
    }
  },
  resolve: {
    // https://cn.vitejs.dev/config/#resolve-alias
    alias: {
      // 设置别名
      '@': path.resolve(__dirname, './src')
    }
  }
})
